package com.dou.sample.opengl_project.samples;

import android.app.ActivityManager;
import android.content.pm.ConfigurationInfo;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

/**
 * Created by Dou on 2018/1/19.
 */

public class PreviewActivity extends AppCompatActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
        ConfigurationInfo deviceConfigurationInfo = activityManager.getDeviceConfigurationInfo();

        boolean supportGL2 = deviceConfigurationInfo.reqGlEsVersion >= 0x20000;

        GLSurfaceView surfaceView = new GLSurfaceView(this);
        PreviewRenderer renderer = new PreviewRenderer(this);

        if (supportGL2){
            surfaceView.setEGLContextClientVersion(2);
            surfaceView.setRenderer(renderer);
        }

        setContentView(surfaceView);
    }
}
